import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class VendingMachineItemTest {
	
	VendingMachineItem myVendingMachineItem;
	
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	/*
	 * This will test the constructor to make sure
	 * it is not null
	 */
	@Test
	public void testVendingMachineItem_WithPositiveValue() {
		myVendingMachineItem = new VendingMachineItem("coke", 1.00);
		assertNotNull(myVendingMachineItem);
	}
	
	/*
	 * This will test the constructor to make sure
	 * it does not accept negative value
	 */
	@Test (expected=VendingMachineException.class)
	public void testVendingMachineItem_WithNegativeValue() {
		myVendingMachineItem = new VendingMachineItem("coke", -1.00);
	}

	/*
	 * This will test the constructor to make sure
	 * it does not accept blank name
	 */
	@Test (expected=VendingMachineException.class)
	public void testVendingMachineItem_WithBlankNameValue() {
		myVendingMachineItem = new VendingMachineItem("", 1.00);
	}

	/*
	 * This will test the constructor to make sure
	 * it returns the same name
	 */
	@Test
	public void testVendingMachineItem_CheckName() {
		myVendingMachineItem = new VendingMachineItem("coke", 1.00);
		assertEquals("coke", myVendingMachineItem.getName());
	}

	/*
	 * This will test the constructor to make sure
	 * it returns the same name
	 */
	@Test
	public void testVendingMachineItem_CheckValue() {
		myVendingMachineItem = new VendingMachineItem("coke", 1.00);
		assertEquals(1.00, myVendingMachineItem.getPrice(), 0.000);
	}
	
	/*
	 * This will test the constructor to make sure
	 * it does not accept a null name
	 */
	@Test (expected=VendingMachineException.class)
	public void testVendingMachineItem_WithNullValue() {
		myVendingMachineItem = new VendingMachineItem(null, 1.00);
	}
	
	/*
	 * This will test the GetName method to make sure it
	 * will return the name the object was initialized with
	 */
	@Test
	public void testGetName_Value() {
		myVendingMachineItem = new VendingMachineItem("coke", 1.00);
		assertEquals("coke", myVendingMachineItem.getName());
	}
	
	/*
	 * This will test the GetName method to make sure it
	 * will return the price the object was initialized with
	 */
	@Test
	public void testGetPrice() {
		myVendingMachineItem = new VendingMachineItem("coke", 1.00);
		assertEquals(1.00, myVendingMachineItem.getPrice(), 0.000);
	}

}
